package com.medusa.aps.business.modules.basic.mp.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.medusa.aps.business.model.pagination.Page;
import com.medusa.aps.business.model.planingscheduing.DeviceWorkingCalendar;
import com.medusa.aps.business.modules.basic.model.input.WorkingCalendarPageParam;
import com.medusa.aps.business.modules.basic.model.output.WorkingCalendarModel;
import com.medusa.aps.business.modules.basic.mp.entity.WorkingCalendar;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Set;

/**
 * 工作日历数据库访问层
 *
 * @author yuxh
 * @since 2023-08-14 17:37:52
 */
public interface WorkingCalendarMapper extends BaseMapper<WorkingCalendar> {

    /**
     * @param deviceIds
     * @return
     */
    List<DeviceWorkingCalendar> getDeviceWorkingCalendars(@Param("deviceIds") Set<Long> deviceIds, LocalDate startDate,LocalDate endDate);

    List<DeviceWorkingCalendar> getDeviceWorkingaCalendar(@Param("deviceId") Long deviceId, LocalDate startDate);

    /**
     * 分页查询设备信息
     *
     * @param query     分页查询参数
     * @param startDate 开始日期
     * @param endDate   结束日期
     * @return 查询结果
     */
    Page<WorkingCalendarModel> deviceCalendarPage(@Param("query") WorkingCalendarPageParam query, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);

    /**
     * 查询指定日期内设备的工作日历
     *
     * @param deviceIds
     * @param startDate
     * @param endDate
     * @return
     */
    List<WorkingCalendar> selectDeviceCalendar(@Param("deviceIds") Set<Long> deviceIds, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);

    /**
     * 查询指定日期内设备的工作日历
     *
     * @param deviceIds
     * @param startDate
     * @return
     */
    Set<Long> selectDeviceIds(@Param("deviceIds") Set<Long> deviceIds, @Param("startDate") LocalDate startDate);

    void saveBatch(@Param("workingCalendars") List<WorkingCalendar> workingCalendars);


    /**
     * 分页查询工作日历
     *
     * @param query     分页查询参数
     * @param startDate 开始日期
     * @param endDate   结束日期
     * @return 查询结果
     */
//    IPage<WorkingCalendarModel> calendarPage(@Param("query") WorkingCalendarPageParam query, @Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
}

